package cn.tedu.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortListDemo3 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("德刚");
        list.add("梁慎海");
        list.add("吴文毅");
        list.add("张樾");
        list.add("阿弥陀佛");
        System.out.println(list);
        Collections.sort(list);
//        Collections.sort(list, new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o2.length()-o1.length();
//            }
//        });
        Collections.sort(list,Comparator.comparingInt(String::length));
        Collections.sort(list,(s1,s2)->s2.length()-s1.length());

        System.out.println(list);
    }
}
